package com.ruoyi.wq.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.wq.mapper.WqIpBlackMapper;
import com.ruoyi.wq.domain.WqIpBlack;
import com.ruoyi.wq.service.IWqIpBlackService;

/**
 * IP黑名单Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-09-05
 */
@Service
public class WqIpBlackServiceImpl extends ServiceImpl<WqIpBlackMapper, WqIpBlack> implements IWqIpBlackService {

    @Autowired
    private WqIpBlackMapper wqIpBlackMapper;

    /**
     * 查询IP黑名单
     * 
     * @param id IP黑名单主键
     * @return IP黑名单
     */
    @Override
    public WqIpBlack selectWqIpBlackById(String id)
    {
        return wqIpBlackMapper.selectWqIpBlackById(id);
    }

    /**
     * 查询IP黑名单列表
     * 
     * @param wqIpBlack IP黑名单
     * @return IP黑名单
     */
    @Override
    public List<WqIpBlack> selectWqIpBlackList(WqIpBlack wqIpBlack)
    {
        return wqIpBlackMapper.selectWqIpBlackList(wqIpBlack);
    }

    /**
     * 新增IP黑名单
     * 
     * @param wqIpBlack IP黑名单
     * @return 结果
     */
    @Override
    public int insertWqIpBlack(WqIpBlack wqIpBlack)
    {
        wqIpBlack.setCreateTime(DateUtils.getNowDate());
        return wqIpBlackMapper.insertWqIpBlack(wqIpBlack);
    }

    /**
     * 修改IP黑名单
     * 
     * @param wqIpBlack IP黑名单
     * @return 结果
     */
    @Override
    public int updateWqIpBlack(WqIpBlack wqIpBlack)
    {
        wqIpBlack.setUpdateTime(DateUtils.getNowDate());
        return wqIpBlackMapper.updateWqIpBlack(wqIpBlack);
    }

    /**
     * 批量删除IP黑名单
     * 
     * @param ids 需要删除的IP黑名单主键
     * @return 结果
     */
    @Override
    public int deleteWqIpBlackByIds(String[] ids)
    {
        return wqIpBlackMapper.deleteWqIpBlackByIds(ids);
    }

    /**
     * 删除IP黑名单信息
     * 
     * @param id IP黑名单主键
     * @return 结果
     */
    @Override
    public int deleteWqIpBlackById(String id)
    {
        return wqIpBlackMapper.deleteWqIpBlackById(id);
    }

	@Override
	public WqIpBlack getIpBlack(String loginIp) {
		QueryWrapper<WqIpBlack> queryWrapper = new QueryWrapper<>();
		WqIpBlack entity = new WqIpBlack();
		entity.setLoginIp(loginIp);
		queryWrapper.setEntity(entity);
		return wqIpBlackMapper.selectOne(queryWrapper);
	}
}
